Merge "Add meta=userinfo&uiprop=latestcontrib"
[lhc/web/wiklou.git] / includes / Title.php
index 0f45839..6d86b22 100644 (file)
@@ -1702,16 +1702,18 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return string Base name
         */
        public function getBaseText() {
+               $text = $this->getText();
                if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
-                       return $this->getText();
+                       return $text;
                }
 
-               $parts = explode( '/', $this->getText() );
-               # Don't discard the real title if there's no subpage involved
-               if ( count( $parts ) > 1 ) {
-                       unset( $parts[count( $parts ) - 1] );
+               $lastSlashPos = strrpos( $text, '/' );
+               // Don't discard the real title if there's no subpage involved
+               if ( $lastSlashPos === false ) {
+                       return $text;
                }
-               return implode( '/', $parts );
+
+               return substr( $text, 0, $lastSlashPos );
        }
 
        /**
@@ -3554,10 +3556,8 @@ class Title implements LinkTarget, IDBAccessObject {
                        $linkCache->clearLink( $this );
                        $this->mArticleID = $linkCache->addLinkObj( $this );
                        $linkCache->forUpdate( $oldUpdate );
-               } else {
-                       if ( $this->mArticleID == -1 ) {
-                               $this->mArticleID = $linkCache->addLinkObj( $this );
-                       }
+               } elseif ( $this->mArticleID == -1 ) {
+                       $this->mArticleID = $linkCache->addLinkObj( $this );
                }
                return $this->mArticleID;
        }
@@ -4804,7 +4804,7 @@ class Title implements LinkTarget, IDBAccessObject {
                $dbw->onTransactionPreCommitOrIdle(
                        function () use ( $dbw ) {
                                ResourceLoaderWikiModule::invalidateModuleCache(
-                                       $this, null, null, $dbw->getDomainId() );
+                                       $this, null, null, $dbw->getDomainID() );
                        },
                        __METHOD__
                );